package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-24
 * Time:1:00
 */
//继承
//子类构造方法 + 初始化（实例代码块、静态代码块和构造方法）

public class Animal {
    public String name;
    public int age;

    //静态代码块
    static {
        System.out.println("父类static-Animal{}");
    }
    //实例代码块
    {
        System.out.println("父类实例-Animal{}");
    }

    public Animal(){
        System.out.println("父类Animal()无参数构造方法");
    }
    public Animal(String name,int age){
        this.name = name;
        this.age = age;
        System.out.println("父类Animal(String,int)带有参数的构造方法");
    }

    public void eat(){
        System.out.println(this.name + "正在吃饭...");
    }
}
